#include <glib.h>

gint main(gint argc, gchar **argv)
{
    GString *string;

    string = g_string_new("hello");
    g_print("ori string: %s \n", string->str);

    g_string_overwrite(string, 1, "aaa");
    g_print("overwrite(1) string: %s \n", string->str);

    g_string_overwrite_len(string, 1, "a\0a", 3);
    g_print("overwrite_len(1,3)string(len:%d): %s \n", (gint)string->len, string->str);

    g_string_printf(string, "%s", "aabbccdd");
    g_string_assign(string, "abcd");
    g_print("assign string(len:%d): %s \n", (gint)string->len, string->str);

    g_string_truncate(string, 2);
    g_print("truncate(2) string(len:%d): %s \n", (gint)string->len, string->str);

    g_string_truncate(string, 0);
    g_print("truncate(0) string(len:%d): %s \n", (gint)string->len, string->str);

    g_string_printf(string, "%s", "aabbccdd");
    g_string_erase(string, 2, 4);
    g_print("erase(2,4) string(len:%d): %s \n", (gint)string->len, string->str);

    g_string_truncate(string, 0);
    g_print("truncate(0) string(len:%d): %s \n", (gint)string->len, string->str);
    g_string_set_size(string, 8);
    g_print("set_size(8)string(len:%d): %s \n", (gint)string->len, string->str);

    g_string_free(string, TRUE);

    return 0;
}
